package com.oracle.erp.client;

import org.apache.log4j.Logger;
import org.apache.wss4j.common.ext.WSPasswordCallback;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import java.io.IOException;

/**
 * web service cleint 添加 用户名密码方法 header
 * Created by zc on 2017/5/2.
 */
public class ClientPasswordCallback implements CallbackHandler {
    private static Logger logger = Logger.getLogger(ClientPasswordCallback.class);

    @Override
    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
        WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
        String ident = "B05_WS_OIS";
        String passwd = "abc123";
        logger.info("ident: " + ", paswd: " + passwd);
        pc.setPassword(passwd);
        pc.setIdentifier(ident);
    }
}
